import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:top_foundation/component/tag.dart';
import 'package:top_foundation/top_foundation.dart';
import 'package:whale/helper/utils/color.dart';
import 'package:whale/helper/utils/img_util.dart';
import 'package:whale/pages/home/main/logic.dart';

import '../../../../helper/global/global.dart';
import '../../../../helper/route/routes.dart';
import '../../../../helper/utils/MyUnderlineTabIndicator.dart';
import '../../../app_tab/controller.dart';

class Explainview extends GetView<HomeLogic> {
  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        Container(
          key: controller.state.keyGreen3,
          padding: EdgeInsets.all(15.r),
          height: 55.r,
          child: Row(
            children: [
              Text(
                '以案释法',
                style: TextStyle(
                    color: ColorsUtil.title,
                    fontSize: 16.r,
                    fontWeight: FontWeight.bold),
              ),
              Spacer(),
              InkWell(
                onTap: () {
                  GlobalState().meansTabIndex.value = 3;
                  final ctrl = Get.find<AppTabController>();
                  ctrl.clickTab(1);
                },
                child: Text(
                  '查看更多',
                  style: TextStyle(color: ColorsUtil.subTitle, fontSize: 12.r),
                ),
              ),
              SizedBox(
                width: 5.r,
              ),
              Image.asset(
                'icon_right.png'.imgPathMe,
                width: 4.5.r,
                height: 8.r,
              )
            ],
          ),
        ),
        Container(
          color: Colors.white,
          margin: EdgeInsets.fromLTRB(15.r, 0, 15.r, 10.r),
          child: ListView.separated(
            itemBuilder: (context, index) {
              return InkWell(
                onTap: () {
                  Get.toNamed(RouterPath.means_detail,
                      arguments: controller.state.docSF[index]);
                },
                child: Container(
                  color: Colors.white,
                  padding:
                      EdgeInsets.symmetric(horizontal: 15.r, vertical: 11.r),
                  child: Row(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      ClipRRect(
                        borderRadius: BorderRadius.circular(4),
                        child: Image.network(
                          'https://img2.baidu.com/it/u=2419815197,1111677397&fm=253&fmt=auto&app=120&f=JPEG?w=1023&h=739',
                          width: 90.r,
                          height: 60.r,
                          fit: BoxFit.cover,
                        ),
                      ),
                      SizedBox(
                        width: 10.r,
                      ),
                      Expanded(
                          child: Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        children: [
                          Text(
                            controller.state.docSF[index].documentTitle ?? '',
                            style: TextStyle(
                              color: ColorsUtil.title,
                              fontSize: 14.r,
                            ),
                          ),
                          SizedBox(
                            height: 5.r,
                          ),
                          Text(
                            '${controller.state.docSF[index].reportType}    ${controller.state.docSF[index].createTime}',
                            style: TextStyle(
                              color: ColorsUtil.subTitle,
                              fontSize: 10.r,
                            ),
                          ),
                        ],
                      ))
                    ],
                  ),
                ),
              );
            },
            padding: EdgeInsets.zero,
            itemCount: controller.state.docSF.length,
            shrinkWrap: true,
            physics: const NeverScrollableScrollPhysics(),
            separatorBuilder: (BuildContext context, int index) => Divider(
              thickness: 0.5,
              height: 0.5,
              color: ColorsUtil.bg,
            ),
          ),
        ),
        SizedBox(
          width: 1.sw,
          height: 120.r,
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.center,
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Text(
                '没有想要的报告/数据？',
                style: TextStyle(color: ColorsUtil.subTitle, fontSize: 12.r),
              ),
              GestureDetector(
                onTap: () => controller.showBottomView(),
                child: Container(
                  decoration: BoxDecoration(
                      borderRadius: BorderRadius.circular(8.r),
                      gradient: const LinearGradient(
                        colors: [Color(0xFF015EEA), Color(0xFF0076FA)],
                        begin: Alignment.centerLeft,
                        end: Alignment.centerRight,
                      )),
                  width: 166.r,
                  padding: EdgeInsets.all(10.r),
                  margin: EdgeInsets.only(top: 10.r),
                  child: Center(
                    child: Text(
                      '我要定制数据',
                      style: TextStyle(color: Colors.white, fontSize: 15.r),
                    ),
                  ),
                ),
              ),
            ],
          ),
        )
      ],
    );
  }
}
